package com.mlick.a.other;

/**
 * @author lixiangxin
 * @date 2019/3/15 23:21
 *
 * 两线程奇偶数打印
 * 1  0
 * 2  1
 * 1 2
 * 2 3
 *
 **/
public class T1 implements Runnable {

    static int s = 1;

    public void run() {

        while (s <= 100) {
            synchronized (T1.class) {

                System.out.println(Thread.currentThread().getName() + "->" + s++);
                T1.class.notifyAll();

                try {
                    T1.class.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }


    public static void main(String[] args) {

        new Thread(new T1()).start();
        new Thread(new T1()).start();
    }
}
